package com.nt.train.service.context;
import com.nt.train.service.ResourceStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
 * @author hlf
 * @version 1.0
 * @date 2022/8/5 10:10
 */
@Component
public class SimpleContext {

    @Autowired
    private final Map<String, ResourceStrategy> strategyMap = new ConcurrentHashMap<>();

    public SimpleContext(Map<String, ResourceStrategy> strategyMap) {
        this.strategyMap.clear();
        strategyMap.forEach((k, v)-> this.strategyMap.put(k, v));
    }

    public String getResource(String poolId){
        return strategyMap.get(poolId).getVpcList(poolId);
    }

}